package logic

import (
	"context"
	"house_srv/houseclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateUserLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserLogic {
	return &UpdateUserLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpdateUserLogic) UpdateUser(req *types.UpdateUserRequest) (resp *types.Response, err error) {
	sms, err := l.svcCtx.HouseRpc.UpdateUser(l.ctx, &houseclient.UpdateUserRequest{
		Mobile:      req.Mobile,
		Name:        req.Name,
		IdCord:      req.IdCord,
		IdCordFront: req.IdCordFront,
		IdCordBack:  req.IdCordBack,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Message: "完善成功",
		Code:    200,
		Data:    sms,
	}, nil

}
